﻿using Microsoft.EntityFrameworkCore;
using StudentsMngDemo.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StudentsMngDemo.Services
{
    public class StudentDataOperation : IStudentDataOperation
    {
        private readonly SdtMngDbContext _sdtMngDbContext;

        public StudentDataOperation(SdtMngDbContext sdtMngDbContext)
        {
            _sdtMngDbContext = sdtMngDbContext;
        }

        public bool AddStudent(Student student)
        {
            _sdtMngDbContext.Students.Add(student);
            if (_sdtMngDbContext.SaveChanges()==1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public List<Student> GetStudents()
        {
            List<Student> students = _sdtMngDbContext.Students.ToList();
            return students;
        }
    }
}
